package com.changou.system.FIlter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;


@Component
public class UrlFilter implements Ordered, GlobalFilter {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("这是第二个过滤器UrlFilter");
        String hostName = exchange.getRequest().getRemoteAddress().getHostName();
        System.out.println("ip"+hostName);
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        //这个一二是给过滤器排序的
        return 2;
    }
}
